<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="missionList">
      <el-table-column label="审批单号" prop="id" align="center" width="120" fixed="left"/>
      <el-table-column label="审批名称" prop="name" align="center" width="200" />
      <el-table-column label="事项id" prop="activityId" align="center" width="150" />
      <el-table-column label="事项类型" prop="activityType" align="center" width="200" />
      <el-table-column label="审批状态" prop="status" align="center" width="200">
        <template slot-scope="scope">
          <span :style="{'color': colors(scope.row.status)}">{{ scope.row.status }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="修改时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleDetail(scope.row)"

          >详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listNeedMeAlready } from "@/api/approve/mission";

export default {
  name: "Already",
  dicts: ['sys_normal_disable'],
  data() {
    return {
      baseUrl: process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 食材表格数据
      missionList: [],
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      }
    };
  },
  activated() {
    this.getList()
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      listNeedMeAlready(this.queryParams).then(response => {
          this.missionList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    handleDetail: function(row) {
      this.$router.push("/approve/detail/" + row.id);
    },
    colors(status) {
      if (status === "通过") {
        return '#2a9c4a'
      } else if (status === "拒绝") {
        return '#FF0000'
      } else if (status === "审批中") {
        return '#fe9f29'
      }
    },
  }
};
</script>
